<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>发起支付-支付</title>
    <script type="text/javascript">
        //调用微信JS api 支付
        function jsApiCall()
        {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',{
                  "appId":"{$jsonData['appId']}",
                  "timeStamp":"{$jsonData['timeStamp']}",
                  "nonceStr":"{$jsonData['nonceStr']}",
                  "package":"{$jsonData['package']}",
                  "signType":"{$jsonData['signType']}",
                  "paySign":"{$jsonData['paySign']}"
                },
                function(res){
                    if (res.err_msg == "get_brand_wcpay_request:ok") { // 支付成功
                        // alert('支付成功');
                        location.href = "{:url('wechat1/chenggong',['order_id'=> $order_id,'price' => $price])}";
                    }
                    if(res.err_msg == "get_brand_wcpay_request:fail") { // 支付失败
                        alert('支付失败');
                        //location.href = '***?type=fail';
                    }
                    if (res.err_msg == "get_brand_wcpay_request:cancel") { // 取消支付
                        alert('取消支付');
                        //location.href = '***?type=cancel';
                    }
                }
            );
        }

        function callpay()
        {
          if (typeof WeixinJSBridge == "undefined"){
              if( document.addEventListener ){
                  document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
              }else if (document.attachEvent){
                  document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                  document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
              }
          }else{
              jsApiCall();
          }
        }
        callpay();
    </script>
</head>
<body>
<div align="center" style="color: #00a157; margin-top: 20%">
    支付中...
</div>
</body>
</html>